function convertImage4x

% FUNCTION CONVERTIMAGE4X browses pictures and select 4x images usd in
% cellDistribution analysis.
% written by Taro Kiritani, tarokiritani2008@u.northwestern.edu 12/14/2010

cd C:\Data\Taro\CELLS

CellList = dir('TK0*');

for m = 500:550 % m = 400 corresponds to TK486. 200-500 (TK332-596): 12/14/2010
    cd C:\Data\Taro\CELLS
    try
        cd([CellList(m).name,'\images']);
        
        % check if there is already a 4x image.
        if exist('x4forCellDistAnalysis.tif')
            error('4x image already exists.')
        end
        
%         % image files are either .fig or .m
%         imlistm = dir('*tif');
%         imlistfig = dir('*fig');
%         imlist = [imlistm;imlistfig];
%                 
%         figlist = figure;
% 
%         for k = 1:length(imlist)
%             try
%                 subplot(3,3,k)
%                 figure(figlist)
%                 imagesc(imread(imlist(k).name))
%             catch
%                 hfig = openfig(imlist(k).name);
%                 figure(figlist)
%                 subplot(3,3,k)
%                 imagesc(get(findobj(hfig,'type','image'),'CData'))
%             end
%                 title(k)
%         end
%         colormap('gray')
%         set(gcf,'Position',[1 1 1200 800])

        imlist = showImageList;

        selectedFig = input('which one?:  ');
        close
        try
            selectedImage = imread(imlist(selectedFig).name);
        catch
            hfig = openfig(imlist(selectedFig).name);
            selectedImage = get(findobj(hfig,'type','image'),'CData');
        end
        figure;
        imagesc(selectedImage)
        colormap('gray')
        imwrite(selectedImage,'x4forCellDistAnalysis.tif','tif')
        pause
        close
    catch
        CellList(m)
        disp('error!')
        pause
    end
    close all
end